From Alexm. Fix mkshort uniqueness on 'anyname' and add option to suppress
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 16 Apr 2003 17:27:44 +0000 (17:27 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 16 Apr 2003 17:27:44 +0000 (17:27 +0000)
uniquification.

gpsbabel/Makefile
gpsbabel/csv_util.c
gpsbabel/xcsv.c

index 430606fdd8d7efc7fd1cb3e27491aa5308aa5a24..d50252d73e66f4240c49ee562a21c5321efe2eb6 100644 (file)
@@ -58,8 +58,8 @@ dep:
        (echo "internal_styles.c: mkstyle.sh" ; ls style/*.style) >> /tmp/dep
        echo Edit Makefile and bring in /tmp/dep
 
-VERSIONU=1_1_1_beta03072003
-VERSIOND=1.1.1_beta03072003
+VERSIONU=1_1_1_beta04162003
+VERSIOND=1.1.1_beta04162003
 release:
        rm -fr gpsbabel-$(VERSIOND)
        cvs tag gpsbabel_$(VERSIONU)
index 038d2585c9bc91f1851de6d4852fbfb41d50b055..84c00348b056331ddb2d5d2546a6222d940396ed 100644 (file)
@@ -579,23 +579,6 @@ xcsv_waypt_pr(const waypoint *wpt)
     field_map_t *fmp;
     queue *elem, *tmp;
 
-    if (wpt->shortname) {
-        anyname = xstrdup(wpt->shortname);
-    } else
-    if (wpt->description) {
-        anyname = mkshort(xcsv_file.mkshort_handle, wpt->description);
-    } else
-    if (wpt->notes) {
-        anyname = xstrdup(wpt->notes);
-    } else
-        anyname = xstrdup("");
-
-    if ((anyname) && (global_opts.synthesize_shortnames)) {
-       char *oldname = anyname;
-        anyname = mkshort(xcsv_file.mkshort_handle, 
-               wpt->notes ? wpt->notes : wpt->description);
-       xfree(oldname);
-    }
     
     if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
         if (wpt->description) {
@@ -644,7 +627,27 @@ xcsv_waypt_pr(const waypoint *wpt)
             sprintf(buff, fmp->printfc, shortname);
         } else
         if (strcmp(fmp->key, "ANYNAME") == 0) {
+            if (wpt->shortname) {
+                anyname = xstrdup(wpt->shortname);
+            } else
+            if (wpt->description) {
+                anyname = mkshort(xcsv_file.mkshort_handle, wpt->description);
+            } else
+            if (wpt->notes) {
+                anyname = xstrdup(wpt->notes);
+            } else
+                anyname = xstrdup("");
+
+            if ((anyname) && (global_opts.synthesize_shortnames)) {
+               char *oldname = anyname;
+                anyname = mkshort(xcsv_file.mkshort_handle, 
+                       wpt->notes ? wpt->notes : wpt->description);
+               xfree(oldname);
+           }
+
             sprintf(buff, fmp->printfc, anyname);
+            
+            xfree(anyname);
         } else
         if (strcmp(fmp->key, "DESCRIPTION") == 0) {
             sprintf(buff, fmp->printfc, description);
@@ -777,9 +780,6 @@ xcsv_waypt_pr(const waypoint *wpt)
     if (description)
         xfree(description);
 
-    if (anyname)
-        xfree(anyname);
-
     index++;
 }
 
index 690e6dfb10c5b544124e4210a67d61ba2a9a6d0d..004413bd50f2f19d2e5c946bedb2c8a48a73c4de 100644 (file)
@@ -34,6 +34,7 @@ static char *styleopt;
 static char *snlenopt;
 static char *snwhiteopt;
 static char *snupperopt;
+static char *snuniqueopt;
 char *xcsv_urlbase;
 
 static
@@ -42,6 +43,7 @@ arglist_t xcsv_args[] = {
        {"snlen", &snlenopt, "Max synthesized shortname length"},
        {"snwhite", &snwhiteopt, "(0/1) Allow whitespace synth. shortnames"},
        {"snupper", &snupperopt, "(0/1) UPPERCASE synth. shortnames"},
+       {"snunique", &snuniqueopt, "(0/1) Make synth. shortnames unique"},
        {"urlbase", &xcsv_urlbase, "Basename prepended to URL on output"},
        {0, 0, 0}
 };
@@ -452,6 +454,9 @@ xcsv_wr_init(const char *fname, const char *args)
         if (snupperopt)
             setshort_mustupper(xcsv_file.mkshort_handle, atoi(snupperopt));
 
+        if (snuniqueopt)
+            setshort_mustuniq(xcsv_file.mkshort_handle, atoi(snuniqueopt));
+
         setshort_badchars(xcsv_file.mkshort_handle, xcsv_file.badchars);
 
     }